import java.io.File;

public class ExtractMain {

	public static void main(String[] args) {
		System.out.println("START.");
		new ExtractMain().run();
		System.out.println("STOP.");
	}

	private void run() {
		File inputFolder = new File("E:\\FILMS\\NOUVEAUX");
		File binFolder = new File(inputFolder, "BIN");
		binFolder.mkdirs();
		File[] files = inputFolder.listFiles();

		for (int i = 0; i < files.length; i++) {
			File current = files[i];

			if (current.isDirectory()) {
				File[] candidatesMovies = current.listFiles();

				for (int j = 0; j < candidatesMovies.length; j++) {
					File candidate = candidatesMovies[j];
					String name = candidate.getName();
					boolean accept = name.endsWith(".mp4")
					|| name.endsWith(".avi")
					|| name.endsWith(".mpg")
					|| name.endsWith(".mkv");
					
					if (accept == false) {
						candidate.renameTo(new File(binFolder, name));
					} else {
						candidate.renameTo(new File(inputFolder, name));
					}
				}
			}
		}
	}

}
